<?php
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();
$input = $app->input;
$getArray = $app->input->getArray();
$campaign = $input->getString('campaign','');
?>
<div class="res-title-rg pos_pre">
    <span class="fl pos-icon text-c"><i class="acquisition"></i></span>
    <div class="title-info">
        <h2 class="fontsize20">CampaignPerformance</h2>
        <p><a href="#">Home</a>&nbsp;/&nbsp;<a href="#">Acquisition</a>&nbsp;/&nbsp;CampaignPerformance</p>
    </div>
</div>
<div class="pdlr15">
	<div class="row tymgbt">
		<div class="col-sm-6">
			<div class="bgwhite bore0 pd-tp-bt pd-lf-rg pos_pre over-hg1">
				<i class="overview-sp over-sp4"></i>
				<h3 class="fontnomal fontsize13">Total Cost</h3>
				<div class="fontsize30 ftbold sp-num">₹<?php echo $getArray['totals']['cptc']?></div>
				<!-- <div class="col6"><span class="bglan colwhite">+17%</span>from previous period</div> -->
			</div>
		</div>
		<div class="col-sm-6">
			<div class="bgwhite bore0 pd-tp-bt pd-lf-rg pos_pre over-hg1">
				<i class="overview-sp over-sp3"></i>
				<h3 class="fontnomal fontsize13">Revenue</h3>
				<div class="fontsize30 ftbold sp-num">₹<?php echo $getArray['totals']['cptr']?></div>
				<!-- <div class="col6"><span class="bglv colwhite">+12%</span>from previous period</div> -->
			</div>
		</div>
	</div>
</div>
<div class="ws-content pdall15 borderall">
	<div class="f-selct-show pos_pre tymgbt">
		<input type="text" class="selecshow fontsize16" placeholder="All Campaign" id="selectext" value="<?php echo $campaign?>" />
		<div class="f-selct-content bgwhite col6 fontsize14">
			<?php foreach($getArray['totals']['cnames'] as $key => $val):?>
			<p><a href="/index.php?option=com_console&view=campaignperformance&Itemid=127&task=CampaignPerformance&campaign=<?php echo $val?>"><?php echo $val?></a></p>
			<?php endforeach;?>
		</div>
	</div>
	<div class="row tymgbt">
		<div class="col-sm-6" id="pie1" style="height: 400px">
		</div>
		<script type="text/javascript">

			<?php if($getArray['pies']['pie1']['legend'] != '[]'):?>
			createPieChart({
				divId: 'pie1',
				title: 'NU per Channel',
				names: <?php echo $getArray['pies']['pie1']['legend'] ?>,
				values: <?php echo $getArray['pies']['pie1']['series'] ?>
			});
			<?php else :?>
			$('#pie1').html('no data');

			<?php endif;?>
		</script>

		<div class="col-sm-6" id="pie2" style="height: 400px">
		</div>
		<script type="text/javascript">
			<?php if($getArray['pies']['pie2']['legend'] != '[]'):?>
			createPieChart({
				divId: 'pie2',
				title: 'VU per Channel',
				names: <?php echo $getArray['pies']['pie2']['legend'] ?>,
				values: <?php echo $getArray['pies']['pie2']['series'] ?>
			});
			<?php else :?>
			$('#pie2').html('no data');
			<?php endif;?>
		</script>

		</div>
		<div class="row tymgbt">
		<div class="col-sm-6" id="pie3" style="height: 400px">
		</div>
		<script type="text/javascript">
			<?php if($getArray['pies']['pie3']['legend'] != '[]'):?>
			createPieChart({
				divId: 'pie3',
				title: 'Cost per Channel',
				names: <?php echo $getArray['pies']['pie3']['legend'] ?>,
				values: <?php echo $getArray['pies']['pie3']['series'] ?>
			});
			<?php else :?>
			$('#pie3').html('no data');
			<?php endif;?>
		</script>
		<div class="col-sm-6" id="pie4" style="height: 400px">
		</div>
		<script type="text/javascript">
			<?php if($getArray['pies']['pie4']['legend'] != '[]'):?>
			createPieChart({
				divId: 'pie4',
				title: 'Installs per Channel',
				names: <?php echo $getArray['pies']['pie4']['legend'] ?>,
				values: <?php echo $getArray['pies']['pie4']['series'] ?>
			});
			<?php else :?>
			$('#pie4').html('no data');
			<?php endif;?>
		</script>
	</div>
 <div class="camtab">
<!--		<nav>
		  <ul class="pagination navmg">
		    <li><a href="#">Copy</a></li>
		    <li><a href="#">Excel</a></li>
		    <li><a href="#">CSV</a></li>
		    <li><a href="#">PDF</a></li>
		  </ul>
		</nav>-->
</div>
	<table class="table table-bordered table-striped">
      <thead>
        <tr class="fontsize14">
          <th>Channel</th>
          <th>Campaign</th>
          <th>City</th>
          <th>News Users</th>
          <th>Valuable Users</th>
          <th>Cost₹</th>
          <th>Revenue₹</th>
        </tr>
      </thead>
      <tbody>
	  <?php foreach($getArray['pies']['lists'] as $key => $val):?>
        <tr>
			<td><?php echo $val['channel']?></td>
          <td><?php echo $val['campaign']?></td>
			<td><?php echo $val['city']?></td>
			<td><?php echo $val['newUsersCount']?></td>
			<td><?php echo $val['valuableUsersCount']?></td>
			<td><?php echo $val['cost']?></td>
			<td><?php echo $val['revenue']?></td>
        </tr>
        <?php endforeach; ?>
      </tbody>
    </table>

</div>
<script>
$(function(){
	$("#selectext").focus(function(){
		$(".f-selct-content").fadeIn();
		$(".f-selct-content p").click(function(){
			$("#selectext").val($(this).text());
			$(".f-selct-content").fadeOut();
		});
	});
})
</script>
